﻿using SuperJoe.Framework.Common;
using SuperJoe.Framework.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WWX.Admin.IDAL;
using WWX.Dto.Search;
using WWX.Model;

namespace WWX.Admin.BLL
{
    public class MemberBLL : BaseBLL<IMemberDAL>
    {
        public void Add(Member model)
        {
            model.CreatedBy = SuperJoeContext.Current.UserId;
            model.CreatedTime = DateTime.Now;
            model.UpdatedBy = SuperJoeContext.Current.UserId;
            model.UpdatedTime = DateTime.Now;
            model.RegisterDate = DateTime.Now;
            model.IsActive = true;
            model.Pwd = MD5.Encrypt3DES(model.Pwd);
            model.Id = Guid.NewGuid().ToString();

            this.dal.Add(model);
        }

        public void Update(Member model)
        {
            model.UpdatedBy = SuperJoeContext.Current.UserId;
            model.UpdatedTime = DateTime.Now;
            this.dal.Update(model);
        }

        public void UpdatePwd(string id, string pwd)
        {
            pwd = MD5.Encrypt3DES(pwd);
            this.dal.UpdatePwd(id, pwd);
        }

        public Member Get(string id)
        {
            return this.dal.Get(id);
        }

        public List<Member> GetPageList(MemberAdminSearch search, int pageNo, int pageSize, out int total)
        {
            return this.dal.GetPageList(search, pageNo, pageSize, out total);
        }
    }
}
